<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 26826
  Date: 2022/5/13
  Time: 15:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/pintuer.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/admin.css">
    <script src="${pageContext.request.contextPath}/js/jquery.js"></script>
    <script src="${pageContext.request.contextPath}/js/pintuer.js"></script>
</head>
<body>
<form method="post" action="${pageContext.request.contextPath}/findAll.action" id="form1">
    <div class="panel admin-panel">
        <div class="panel-head"><strong class="icon-reorder">身份证管理</strong></div>
        <div class="padding border-bottom">
            <ul class="search">
                <li>
                    <button type="button"  class="button border-green" id="checkall"><span class="icon-check"></span>全选</button>
                    <button type="button" class="button border-red" onclick="deletes()"><span class="icon-trash-o"></span>批量删除</button>
                    <a class="button border-yellow" href="${pageContext.request.contextPath}/appendIdcard.action"><span class="icon-plus"></span>添加身份证</a>
                    <select id="factor" name="factor" style=" background-color: whitesmoke; padding:10px 15px; border:1px solid #ddd; border-radius:5px ">
                        <option value="">请选择</option>
                        <option value="userid">id</option>
                        <option value="username">用户名</option>
                        <option value="role">权限</option>
                    </select>
                    <input type="text" placeholder="请输入搜索关键字" id="keywords" name="keywords" class="input" style="width:250px; line-height:17px;display:inline-block">
                    <a href="javascript:void(0)" class="button border-main icon-search" onclick="factorQuery()"> 搜索</a></li>
            </ul>
        </div>
        <table class="table table-hover text-center">
            <tr>
                <th width="120">编号</th>
                <th>姓名</th>
                <th>性别</th>
                <th>年龄</th>
                <th>身份证号</th>
                <th>开始时间</th>
                <th>到期时间</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${idcards}" var="use" varStatus="st">
                <tr>
                    <td><input type="checkbox" name="id" value="${use.idcard_id}" />${st.count}</td>
                    <td>${use.employee.employee_name}</td>
                    <td>${use.employee.employee_sex}</td>
                    <td>${use.employee.employee_age}</td>
                    <td>${use.idcard_num}</td>
                    <td>${use.idcard_starttime}</td>
                    <td>${use.idcard_endtime}</td>
                    <td><div class="button-group">
                        <a class="button border-red" href="javascript:void(0)" onclick="return del(${use.idcard_id})"><span class="icon-trash-o"></span> 删除</a>
                        <a class="button border-main" href="${pageContext.request.contextPath}/jumpPage.action?userid=${use.idcard_id}"><span class="icon-edit"></span> 修改</a>
                    </div></td>
                </tr>
            </c:forEach>
            <tr>
                <td colspan="8">
                    <div class="pagelist">
                        <a href="${pageContext.request.contextPath}/findAllIdcard.action?pageNum=1">首页</a>
                        <a href="${pageContext.request.contextPath}/findAllIdcard.action?pageNum=${idcardPageInfo.pageNum==1?1:idcardPageInfo.pageNum-1}">上一页</a>
                        <c:forEach begin="1" end="${idcardPageInfo.pages}" step="1" var="numPage">
                            <a href="${pageContext.request.contextPath}/findAllIdcard.action?pageNum=${numPage}">${numPage}</a>
                        </c:forEach>
                        <a href="${pageContext.request.contextPath}/findAllIdcard.action?pageNum=${idcardPageInfo.pageNum==idcardPageInfo.pages?idcardPageInfo.pages:idcardPageInfo.pageNum+1}">下一页</a>
                        <a href="${pageContext.request.contextPath}/findAllIdcard.action?pageNum=${idcardPageInfo.pages}">尾页</a>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</form>
<script type="text/javascript">

    function deletes(){
        if(confirm("您确定要删除吗？")){
            $("#form1").submit();
        }
    }
    <%--    条件搜索   --%>
    function factorQuery(){
        window.location.href="${pageContext.request.contextPath}/userServlet?method=factorQuery&factor="+$("#factor").val()+"&keywords="+$("#keywords").val();
    }

    function del(id){
        if(confirm("您确定要删除这个身份证吗?")){
            window.location.href="${pageContext.request.contextPath}/removeIdcard.action?idcard_id="+id;
        }
    }

    $("#checkall").click(function(){
        $("input[name='id']").each(function(){
            if (this.checked) {
                this.checked = false;
            }
            else {
                this.checked = true;
            }
        });
    })

    function DelSelect(){
        var Checkbox=false;
        $("input[name='id']").each(function(){
            if (this.checked==true) {
                Checkbox=true;
            }
        });
        if (Checkbox){
            var t=confirm("您确认要删除选中的内容吗？");
            if (t==false) return false;
        }
        else{
            alert("请选择您要删除的内容!");
            return false;
        }
    }

</script>
</body></html>